
#include <iostream>
#include <string>
#include <vector>
#include <functional>

using namespace std;

template<class T>
void _test_list(const T& x)
{
	cout << x << endl;
}

template<class T, class ...Args>
void _test_list(const T& x, Args... args)
{
	cout << x << ' ';
	_test_list(args...);
};

template<class ...Args>
void test_list(Args... args)
{
	_test_list(args...);
};

struct date
{
	date(int year, int month, int day) = delete;
	
	int _year;
	int _month;
	int _day;
};

template<class T>
struct ListNode
{
	ListNode<T>* _next;
	ListNode<T>* _prev;
	T _data;

	ListNode(const T& x = T())
		:_next(nullptr)
		, _prev(nullptr)
		, _data(x)
	{}

	ListNode(T&& x)
		:_next(nullptr)
		, _prev(nullptr)
		, _data(forward<T>(x))
	{}

	template<class ...Args>
	ListNode(Args... args)
		: _next(nullptr)
		, _prev(nullptr)
		, _data(forward<Args>(args)...)
	{}

};

template<class T>
class List
{
	typedef ListNode<T> Node;
public:		
	iterator begin()
	{
		return _head->_next;
	}

	iterator end()
	{
		return _head;
	}

	iterator insert(iterator pos, const T& x)
	{
		Node* cur = pos._node;
		Node* prev = cur->_prev;
		Node* newnode = new Node(x);

		prev->_next = newnode;
		newnode->_prev = prev;
		newnode->_next = cur;
		cur->_prev = newnode;

		return newnode;
	}

	iterator insert(iterator pos, T&& x)
	{
		Node* cur = pos._node;
		Node* prev = cur->_prev;
		Node* newnode = new Node(forward<T>(x));

		prev->_next = newnode;
		newnode->_prev = prev;
		newnode->_next = cur;
		cur->_prev = newnode;

		return newnode;
	}

	template<class ...Args>
	iterator insert(iterator pos, Args... args)
	{
		Node* cur = pos._node;
		Node* prev = cur->_prev;
		Node* newnode = new Node(forward<Args>(args)...);

		prev->_next = newnode;
		newnode->_prev = prev;
		newnode->_next = cur;
		cur->_prev = newnode;

		return newnode;
	}

	template<class T>
	void push_back(const T& x)
	{
		insert(end(), x);
	}

	template<class T>
	void push_back(T&& x)
	{
		insert(end(), forward<T>(x));
	}

	template<class ...Args>
	void emplace_back(Args&&... args)
	{
		insert(end(), forward<Args>(args)...);
	}
private:
	Node* _head = nullptr;
};

struct Goods
{
	string _name;
	int _price;
	int _value;
	int _sales;
};

void test1()
{
	string s("abcd");
	char ch = 'x';
	int i = 1;
	double d = 2.2;
	test_list(s, i, ch, d);
}

//void test2()
//{
//	date d1(2025, 2, 6);
//}

//void test3()
//{
//	vector<Goods> goods = { { "computer", 5000, 8, 500 }, { "iphone", 9000, 9, 150 }, { "ipad", 8500, 8, 200 } };
//	qsort(goods.begin(), goods.end(), [](const Goods& good1,const Goods& good2){
//		return good1._price < good2._price; });
//	qsort(goods.begin(), goods.end(), [](const Goods& good1, const Goods& good2){
//		return good1._price > good2._price; });
//	qsort(goods.begin(), goods.end(), [](const Goods& good1, const Goods& good2){
//		return good1._sales < good2._sales; });
//	qsort(goods.begin(), goods.end(), [](const Goods& good1, const Goods& good2){
//		return good1._sales > good2._sales; });
//}

int sub(int a, int b)
{
	return a - b;
}

void test4()
{
	int x = 1, y = 2;
	int d = sub(x, y);
	cout << d << endl;

	auto func1 = bind(sub, placeholders::_2, placeholders::_1);
	d = func1(x, y);
	cout << d << endl;
}

int main()
{
	//test1();
	//test2();
	//test3();
	test4();
	return 0;
}